package actions;

import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import forms.DegreeForm;

public class AdditionalDegreesAction extends Action {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		String additional = (String)request.getParameter("additional");
		
		DegreeForm iForm = (DegreeForm) form;
		
		HashMap oldDegree = new HashMap();
		
		oldDegree.put("location", iForm.getLocation());
		oldDegree.put("university", iForm.getUniversity());
		oldDegree.put("discipline", iForm.getDiscipline());
		oldDegree.put("month", iForm.getMonth());
		oldDegree.put("year", iForm.getYear());
		oldDegree.put("gpa", iForm.getGpa());
		oldDegree.put("title", iForm.getTitle());
		
		iForm.addDegree(oldDegree);
		
		if (additional.equals("true")) {
			iForm.setLocation(null);
			iForm.setUniversity(null);
			iForm.setDiscipline(null);
			iForm.setMonth(null);
			iForm.setYear(null);
			iForm.setGpa(null);
			iForm.setTitle(null);
	    	return mapping.findForward("moresuccess");
		}
		else {
	    	return mapping.findForward("donesuccess");
		}
	}
}